home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
170_01
/
addlf.c
< prev
next >
Wrap
Text File
|
1980-01-01
|
768b
|
25 lines
/* addlf -- copy input to output; add line-feeds only if necessary.
* WHRauser 10-4-83 a better mouse trap.
*/
#include <stdio.h> /* Microsoft C Ver 1.04 */
#define CR 0x000D /* carriage return */
#define LF 0x000A /* line feed */
#define TRUE 1
#define FALSE 0
main() /* copy input to output and add line-feeds only if needed. */
{
int c;
int addlf = FALSE;
while ((c = getchar()) != EOF) {
if (addlf & c != LF) {
putchar(LF);
addlf = FALSE;
}
putchar(c);
if (c == CR) addlf = TRUE;
}
}